package com.itheima;

import com.itheima.service.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

//第五步，表现层（App）通过spring获取资源（Service实例）
public class UserApp {
    public static void main(String[] args) {
        //2，加载配置文件
        ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
        //3，获取资源
//        注意，都是获取的userService3，测试单例和多例
        UserService userService1 = (UserService) ctx.getBean("userService3");
        UserService userService2 = (UserService) ctx.getBean("userService3");
        UserService userService3 = (UserService) ctx.getBean("userService3");

        System.out.println(userService1);
        System.out.println(userService2);
        System.out.println(userService3);
        System.out.println(userService1 == userService3);

//        userService.save();
    }
}
